# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-cymem
pkgver=2.0.8
pkgrel=1
pkgdesc="Cython memory pool for RAII-style memory management"
url="https://github.com/explosion/cymem"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('python')
makedepends=('cython' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest')
source=("https://github.com/explosion/cymem/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('1428270b67def1a5f4fe94b7958e57c201ac021c6ee40420fab222bb66d99c4dc77db7d794c90c3772f5a2e2a504347928591073e7fa2fd2fa31691899632b38')

build() {
  cd cymem-$pkgver
  python -m build --no-isolation --wheel
}

check() {
  cd cymem-$pkgver

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  python -m installer -d "tmp_install" dist/cymem-*.whl
  cd tmp_install/$site_packages
  pytest cymem
}

package() {
  cd cymem-$pkgver
  python -m installer -d "$pkgdir" dist/cymem-*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
